<?php

/**
 * Class AccountController
 */
class ShopUserController extends BaseController
{

    public function __construct(){
        parent::__construct();
//权限控制
        $info = session_get(UserEnum::USER_INFO_SESSION_KEY);
        if(empty($info)){

            echo "<script>alert('你还没有登录,请重新登陆');location='/login';</script>";die();

//      echo"<script>Showbo.Msg.nameauth('你还没有登录,请重新登陆',function(){
            //      location='/login';
            // })</script>";

        }
    }


#—————————————————————————————个人中心——————————————————————————————
    /**
     * @return mixed
     * 账户信息
     */
    public function UserAccount(){
        $token = QiniuUpload::instance()->generateToken();
        return $this->view("shop.shop_user_account")->with('token',$token);
    }

    /**
     * @return mixed
     * 账户信息修改
     */
    public function UserAccountModify(){

            #接受参数
            $paramObj                     =          new stdClass();
            $paramObj->phone              =          $this->getParam('phone');         //联系电话
            $paramObj->user_name          =          $this->getParam('user_name');         //用户名
            $paramObj->corporation        =          $this->getParam('corporation');             //公司名
            $paramObj->address            =          $this->getParam('address');             //地址
            $paramObj->avatar              =          $this->getParam('avatar');             //头像
            #逻辑处理
            try{
                return   ShopService::instance()->UserAccountModify($paramObj);
            }catch (Exception $e){
                print $e->getMessage();
            }

    }


    /**
     * @return mixed
     * 现货添加
     */
    public function AjaxPlace(){
        $hotcity = ShopService::instance()->CitySelect();
        return $hotcity;
    }


    /**
     * @return mixed
     * 现货添加
     */
    public function UserNowResource(){
        if(session_get(UserEnum::USER_INFO_SESSION_KEY)->is_supplier){
            $category = AdminService::instance()->ShowProductCategory();
            $company = ShopService::instance()->GetSupplierInfo(session_get(UserEnum::USER_INFO_USER_ID))->company;
            $old_name = HostEnum::EXCEL_NAME;
            return $this->view("shop.shop_user_resource_release")->with(['category'=>$category,'company'=>$company,'old_name'=>$old_name]);
        }else{
            return Redirect::to('/user_seller_join');
        }
    }


    /**
     * @return mixed
     * 现货入库
     */
    public function UserAddNowResource(){
            #收集信息
            $paramObj                   =          new stdClass();
            $paramObj->city             =          $this->getParam('city');
            $paramObj->factory          =          $this->getParam('factory');               //详细地址
            $paramObj->content          =          $this->getParam('content');               //公司
            $paramObj->classes          =          $this->getParam('classes');
            $paramObj->down_address     =          $this->getParam('down_address');

            #逻辑处理
                $re = ShopService::instance()->UserAddNowResource($paramObj);
                if($re){
                    return 1;
                }

    }

    /**
     * ADD excel文件
     */
    public function AddExcel(){
        $file           =      $_FILES;
        $clientName = $file['file_ex']['name'];
        $entension = substr($file['file_ex']['name'],strripos($file['file_ex']['name'],'.')); //上传文件的后缀.
        $newName = md5(date('ymdhis').$clientName).$entension;
        move_uploaded_file($_FILES["file_ex"]["tmp_name"], "resource/SDK/".$newName);
        return "resource/SDK/".$newName;
    }


    /**
     * @return mixed
     * 现货管理
     */
    public function UserNowResourceAdmin(){
        if(session_get(UserEnum::USER_INFO_SESSION_KEY)->is_supplier){
            $user_id = session_get(UserEnum::USER_INFO_USER_ID);
            $list = ShopService::instance()->UserNowResourceAdmin($user_id);
            return $this->view("shop.shop_user_resource_list")->with('list',$list);
        }else{
            return Redirect::to('/user_seller_join');
        }
    }

    /**
     * @return mixed
     * 现货删除
     */
    public function NowResourceDelete(){
        #接受参数
        $paramObj                     =          new stdClass();
        $paramObj->product_id          =          $this->getParam('product_id');         //现货ID
        $list = ShopService::instance()->NowResourceDelete($paramObj);
        $this->rest->success(['state' => $list], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 现货删除ajax返回模板
     * @return mixed
     * @author fyl
     * @date 2016-06-29
     */
    public function NowResourceAjax()
    {
        $user_id = session_get(UserEnum::USER_INFO_USER_ID);
        $info = ShopService::instance()->UserNowResourceAdmin($user_id);
        return $this->viewAjax('shop.ajaxTemplates.new_resource_part')->with('list', $info);
    }


    /**
     * @return mixed
     * 现货下载
     */
    public function DownNewResource(){
        #接受参数
        $paramObj                     =          new stdClass();
        $paramObj->down_num           =          $this->getParam('down_num');         //现货ID
        $paramObj->product_id           =          array($this->getParam('product_id'));
        $num = ShopService::instance()->DownNewResource($paramObj);
        $this->rest->success(['state' => $num], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * @return mixed
     * 个人中心发布采购单
     */
    public function UserPurchaseResource(){
        return $this->view("shop.shop_user_purchase_resource");
    }

    /**
     * @return mixed
     * 个人中心采购单管理
     */

    public function UserPurchaseResourceAdmin(){
        try{
            $data = ShopService::instance()->PurchaseResourceAdmin();

                return $this->view("shop.shop_user_purchase_resource_admin")->with('data',$data);

        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
        return $this->view("shop.shop_user_purchase_resource_admin");
    }
    /**
     * @return mixed
     * 个人中心采购单删除
     */
    public function UserPurchaseResourceDel(){
        $paramObj = new stdClass();
        $paramObj->purchase_id = $this->getParam('purchase_id');   //id
        $id= ShopService::instance()->UserPurchaseResourceDel($paramObj->purchase_id);
        if($id = 1){

            try{
                $data = ShopService::instance()->PurchaseResourceAdmin();
                if($data){
                    return $this->view("shop.shop_user_purchase_resource_admin")->with('data',$data);
                }
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }


        }else{

            return $this->view("shop.shop_user_purchase_resource_admin");
        }






    }

    /**
     * @return mixed
     */
    public function UserReceiptAddress(){
        $paramObj = new stdClass();
        $paramObj->user_id =session_get(UserEnum::USER_INFO_USER_ID);   //user_id
        try{
            $data = ShopService::instance()->UserReceiptAddress($paramObj->user_id);
                return $this->view("shop.shop_user_receipt_address")->with('data',$data);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

        return $this->view("shop.shop_user_receipt_address");
    }

    /**
     * @return mixed
     * 商家入驻
     */
    public function UserSellerJoin(){
        $status = ShopService::instance()->GetSupplierStatus();
        return $this->view("shop.shop_user_seller_join")->with('status',$status);
    }


    /**
     * @return mixed
     * 商家入驻
     */
    public function UserSellerJoinEstablishment(){
        $paramObj                         =          new stdClass();
        $paramObj->user_id                =            session_get(UserEnum::USER_INFO_USER_ID);
        $paramObj->invite_code            =          $this->getParam('invite_code');         //邀请码
        $status = ShopService::instance()->UserSellerJoinEstablishment($paramObj);
        return $status;
    }

    /**
     * @return mixed
     * 商家重新入住
     */
    public function UpdateUserSellerJoin(){
        $status = 3;
        $user_id                  =            session_get(UserEnum::USER_INFO_USER_ID);
        $seller_info = ShopService::instance()->GetSupplierInfo($user_id);
        return $this->view("shop.shop_user_seller_join")->with(['status'=>$status,'info'=>$seller_info]);
    }


    /**
     * @return mixed
     * 商家入驻信息入库
     */
    public function UserSellerJoinInfo(){
        #接受参数
        $paramObj                               =          new stdClass();
        $paramObj->supplier_id                  =                  $this->getParam('supplier_id');
        $paramObj->user_id                      =            session_get(UserEnum::USER_INFO_USER_ID);
        $paramObj->supplier_name                =          $this->getParam('supplier_name');            //商家名称
        $paramObj->company                      =          $this->getParam('supplier_name');            //公司名称
        $paramObj->address                      =          $this->getParam('address');                  //公司地址
        $paramObj->duty_name                    =          $this->getParam('duty_name');                //负责人名称
        $paramObj->duty_mobile                  =          $this->getParam('duty_mobile');              //负责人电话
        $paramObj->operate_license              =          $this->getParam('operate_license');          //营业执照
        $paramObj->organization                 =          $this->getParam('organization');             //组织机构代码证
        $paramObj->tax_license                  =          $this->getParam('tax_license');              //税务登记证
        $paramObj->account_licence              =          $this->getParam('account_licence');//开户许可证
        $status = ShopService::instance()->UserSellerJoinInfo($paramObj);
        if($status){
            return Redirect::to('/user_seller_join');
        }

    }


    /**
     * 09.09
     *修改密码
     *
     *
     */
    public function UserAmend_pass(){
        return $this->view("shop.shop_user_password")->with('user_id',session_get(UserEnum:: USER_INFO_USER_ID));
    }
    /**
     * 查询密码是否正确
     */
    public function UserPasswordSelect()
    {
        $paramObj = new stdClass();
        $paramObj->user_id = $this->getParam('user_id');   //id
        $paramObj->old_password = $this->getParam('password');   //id

        $id = ShopService::instance()->UserPasswordSelect($paramObj->user_id, $paramObj->old_password);
        if($id == 1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;
    }
    public function UserPasswordUpdate(){
        $paramObj = new stdClass();
        $paramObj->user_id = $this->getParam('user_id');   //id
        $paramObj->old_password = $this->getParam('old_password');   //id
        $paramObj->new_password = $this->getParam('new_password');   //id


        $id = ShopService::instance()->UserPasswordSelect($paramObj->user_id, $paramObj->old_password);
        if($id == 1){
            $ids= ShopService::instance()->UserPasswordUpdate($paramObj->new_password,$paramObj->user_id );
            if($ids==1){
                $rs['code']=1;
            }else{
                $rs['code']=0;
            }
        }else{
            $rs['code']=0;
        }
        return $rs;
    }
    /**
     * 09.09
     *个人主页
     *
     *
     */
    public function UserPerson(){
        $paramObj = new stdClass();
        $paramObj->user_id           =   session_get(UserEnum::USER_INFO_USER_ID);      //用户ID
        $data = ShopService::instance()->UserPerson($paramObj->user_id);
        $my_message = count(ShopService::instance()->UserMessage($paramObj->user_id,1));
        $system_message = count(ShopService::instance()->UserMessage($paramObj->user_id,2)) ;
        $token = QiniuUpload::instance()->generateToken();
        $user_id =   session_get(UserEnum::USER_INFO_USER_ID);
        #个人资源单关注
        $user_follow = ShopService::instance()->UserFollow($paramObj->user_id);
        return $this->view("shop.shop_user_homepage")->with(['user'=>$data,'my_message'=>$my_message,'system_message'=>$system_message,'token'=>$token,'user_id'=>$user_id,'user_follow'=>$user_follow]);
    }

    /**
     *个人中心关注AJAX
     */
    public function AjaxUserFollow(){
        $user_id =   session_get(UserEnum::USER_INFO_USER_ID);
        $user_follow = ShopService::instance()->UserFollow($user_id);
        return $this->viewAjax('shop.ajaxTemplates.shop_user_follow_part')->with('user_follow',$user_follow);
    }

    /**
     *
     * 个人主页头像修改
     *
     */
    public function AvatarUpdate(){
        $paramObj = new stdClass();
        $paramObj->user_id           =   session_get(UserEnum::USER_INFO_USER_ID);      //用户ID
        $paramObj->avatar           =   $this->getParam('avatar');
        $data = ShopService::instance()->AvatarUpdate($paramObj->user_id,$paramObj->avatar);
        if($data==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;
    }


    /**
     * @return mixed
     *
     * 订单
     * 09.08
     */
    public function UserOrder(){
        $paramObj = new stdClass();
        $paramObj->user_id           =   session_get(UserEnum::USER_INFO_USER_ID);      //用户ID
        $paramObj->status           =   $this->getParam('status');      //订单状态
        try{
            $data = ShopService::instance()->GetOrderAllPc($paramObj->user_id ,$paramObj->status );
            return $this->view("shop.shop_user_order_list") ->with('data',$data);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

        return $this->view("shop.shop_user_order_list");

    }


    /**
     * @return mixed
     * 订单显示条数
     * 09.08
     */
    public function UserOrderNum(){
        $paramObj = new stdClass();
        $paramObj->user_id           =   session_get(UserEnum::USER_INFO_USER_ID);      //用户ID
        $paramObj->status           =   $this->getParam('status');
        $data = ShopService::instance()->GetOrderAllPc($paramObj->user_id ,$paramObj->status );
        $num=count($data);
        $rs['code']=$num;
        return $rs;

    }

    /**
     * @return mixed
     * @throws Exception
     * 订单取消(状态是未支付)
     * 09.08
     */
    public function CancelOrderNoPay()
    {
        #收集信息
        //$paramObj                    =   new stdClass();
        $paramObj = new stdClass();
        $paramObj->order_id           =   $this->getParam('order_id');

        #逻辑处理
        $data = ApiService::instance()->CancelOrder( $paramObj->order_id);
        //库存恢复
        $kc = ApiService::instance()->kcback( $paramObj->order_id);
        ApiService::instance()->UpdateUseable($kc->product_id,$kc->number);
        ApiService::instance()->UpdateLocking($kc->product_id,$kc->number);
        if($data==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;

    }
    /**
     * @return mixed
     * @throws Exception
     * 订单取消(状态是未审核)
     * 09.08
     */
    public function CancelOrderNoLock()
    {
        #收集信息
        //$paramObj                    =   new stdClass();
        $paramObj = new stdClass();
        $paramObj->order_id           =   $this->getParam('order_id');

        #逻辑处理
        $data = ApiService::instance()->CancelOrder( $paramObj->order_id);
        //库存恢复
        if($data==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;

    }
    /**
     * @return mixed
     * @throws Exception
     * 订单删除
     * 09.08
     */
    public function DelOrderPc()
    {
        #收集信息
        //$paramObj                    =   new stdClass();
        $paramObj = new stdClass();
        $paramObj->order_id           =   $this->getParam('order_id');
        $data = ShopService::instance()->DeleteOrder($paramObj->order_id );
        if($data==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;
    }

    /**
     * @return mixed
     * @throws Exception
     * 确认提货
     * 09.08
     */
    public function ConfirmReceipt(){
        $paramObj = new stdClass();
        $paramObj->order_id           =   $this->getParam('order_id');

        #逻辑处理
         $data = ApiService::instance()->ConfirmReceipt($paramObj->order_id);
        //减锁库，减实际库存
        $kc = ApiService::instance()->kcback( $paramObj->order_id);
        ApiService::instance()->UpdateLocking($kc->product_id,$kc->number);
        ApiService::instance()->UpdateReal($kc->product_id,$kc->number);
        if($data==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;
    }
    /**
     * @return mixed
     * 订单详情
     * 09.08
     */
    public function OrderDetailPc()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->order_id = $this->getParam('order_id');

        #逻辑处理

        $data = ShopService::instance()->OrderDetail($paramObj->order_id);

        return $this->view("shop.shop_user_order_details")->with('data', $data);

    }
    /**
     * 添加购物车
     * @author fyl
     * @data  2016-7-01
     */
    public function ShopAddCart()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');
        $paramObj->number            =   1;
        #逻辑处理
        try{
            $data = ShopService::instance()->ShopAddCart($paramObj);
            return $this->viewAjax('shop.ajaxTemplates.cart_head_part')->with('data',$data);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 购物车列表
     * @author fyl
     * @data  2016-7-01
     */
    public function ShopCartList()
    {
        #逻辑处理
        try{
            $data = ShopService::instance()->ShopCartList();
            $sum = ShopService::instance()->ShopCartSum();
            $count = ShopService::instance()->ShopCartCount();
            return $this->view('shop.shop_user_cart_list')->with(['data'=>$data,'count'=>$count,'sum'=>$sum]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 删除购物车商品
     * @author fyl
     * @data  2016-7-02
     */
    public function ShopCartDelete()
    {
        #接受参数
        $paramObj                     =          new stdClass();
        $paramObj->cart_id           =          $this->getParam('cart_id');
        $list = ShopService::instance()->ShopCartDelete($paramObj);
        $this->rest->success(['state' => $list], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');

    }

    /**
     * 购物车更新商品
     * @author fyl
     * @data 2016-7-8
     */
    public function ShopUpdateCart()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');
        $paramObj->down_num       =   $this->getParam('down_num');

       return ShopService::instance()->ShopUpdateCart($paramObj);

    }

    /**
     * 删除购物车商品
     * @author fyl
     * @data  2016-7-02
     */
    public function HeadCartDelete()
    {
        #接受参数
        $paramObj                     =          new stdClass();
        $paramObj->cart_id           =          $this->getParam('cart_id');         //现货ID
        $list = ShopService::instance()->HeadCartDelete($paramObj);
        if($list){
            return Redirect::back();
        }

    }


    /**
     * 购物车删除ajax返回模板
     * @return mixed
     * @author fyl
     * @date 2016-08-19
     */
    public function ShopCartAjax()
    {
        $info = ShopService::instance()->ShopCartList();
        $sum = ShopService::instance()->ShopCartSum();
        $count = ShopService::instance()->ShopCartCount();
        $cart_id = ShopService::instance()->GetCartId();
        return $this->viewAjax('shop.ajaxTemplates.shop_cart_part')->with(['data'=>$info,'count'=>$count,'sum'=>$sum,'cart_id'=>$cart_id]);
    }

    /**
     * 提交购物车
     * @return mixed
     * @author fyl
     * @date 2016-09-5
     */
    public function ShopCartSubmit()
    {
        //$user_id = session_get(UserEnum::USER_INFO_USER_ID);
        $cart_id           =   $this->getParam('cart_id');
        $user_id = session_get(UserEnum::USER_INFO_USER_ID);
        $sub = substr($cart_id,0,strrpos($cart_id,','));
        $cart_id = explode(',',$sub);
        $cart_info = ShopService::instance()->ShopCartInfo($cart_id);
        $sum = ShopService::instance()->ShopSubmitCartSum($sub);
        $supplier = ShopService::instance()->GetSupplierInfo($user_id);
        if(empty($cart_info)){
         return Redirect::to('/user_order?status=0');
        }
        $cart_list_info= [
          'cart_id' => $sub,
          'cart_info'=> $cart_info,
          'supplier_info'=>$supplier,
            'sum'         =>$sum,
        ];
        return $this->view('shop.shop_user_cart_submit')->with('cart_list_info',$cart_list_info);
    }

    /**
     * 生成订单
     * @author fyl
     * @date 2016-7-8
     */
    public function ShopGenerateOrder()
    {
        #收集信息
        $paramObj                      =   new stdClass();
       // $paramObj->address_id          =   $this->getParam('address_id');
        $paramObj->pay                         =   $this->getParam('pay');
        $paramObj->cart_id             =   $this->getParam('cart_id');

        #逻辑处理
        try{
            $status =  ShopService::instance()->ShopGenerateOrder($paramObj);
            if(empty($order_id)){
                return $status;
            }
            $this->JdPayFirst($order_id);
            return $this->view('shop.shop_user_cashier');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * @return mixed
     * 订单支付
     */
    public function JdPayFirst($order_id){
        $data = ApiService::instance()->SelectOrder($order_id );
        $data['order_id']=$order_id;
        $_SESSION['array'] = $data;
        // $config = Config::get("jd_pay");
        // $serverPayUrl = $config["serverPayUrl"];

    }

    /*
     * 设为默认地址
     */
    public function DefaultAddress(){
        $paramObj = new stdClass();
        $paramObj->address_id           =   $this->getParam('address_id');

        #逻辑处理
        $data = ApiService::instance()->ModifyIsDefault1($paramObj->address_id);

        if($data['is_default']==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;
    }
    //删除收货地址
    public function DeleteAddress(){
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //地址ID
        $paramObj->is_default       =         0;               //是否默认地址

        #逻辑处理
        $data = ApiService::instance()->DeleteAddress($paramObj);
        if($data->status==1){
            $rs['code']=1;
        }else{
            $rs['code']=0;
        }
        return $rs;



    }

    //修改查询
    public function UpdateSelect(){
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //地址ID
        #逻辑处理
        $data = ShopService::instance()->UpdateSelect($paramObj->address_id);
        if($data){
            $rs['code']=1;
            $rs['address_id']=$data->address_id;
            $rs['consignee']=$data->consignee;
            $rs['mobile']=$data->mobile;
            $rs['address']=$data->address;
            $rs['address_all']=$data->address_all;

        }else{
            $rs['code']=0;
        }
        return $rs;



    }

    public function UpdateAddress(){
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //地址ID
        $paramObj->is_default       =          $this->getParam('is_default');
        $paramObj->consignee       =          $this->getParam('consignee');
        $paramObj->mobile       =          $this->getParam('mobile');
        $paramObj->address_all       =          $this->getParam('address_all');
        $paramObj->address       =          $this->getParam('address');
        $data = ShopService::instance()->ModifyAddress($paramObj);
        if(!empty($data)){
            $rs['code']=1;

        }else{
            $rs['code']=0;
        }
        return $rs;

    }
    /**
     *
     * 开发票
     * 09.12
     */
    public function AddInvoice(){
        $paramObj                   =          new stdClass();
        $paramObj->order_id       =          $this->getParam('order_id');
        $paramObj->title       =          $this->getParam('title');
        $paramObj->address       =          $this->getParam('address');
        $paramObj->phone       =          $this->getParam('phone');
        $paramObj->addressee       =          $this->getParam('addressee');
        $data = ShopService::instance()->AddInvoice($paramObj);
        if(!empty($data)){
            $rs['code']=1;

        }else{
            $rs['code']=0;
        }
        return $rs;
    }
    /**
     *
     * 发票查询
     * 09。13
     *
     */
    public function SelectInvoice(){
        $paramObj                   =          new stdClass();
        $paramObj->user_id       =         session_get(UserEnum::USER_INFO_USER_ID);
        $title = ShopService::instance()->SelectTitle($paramObj->user_id);
        if(Request::isMethod('POST')) {
            $paramObj->start_time1      =          $this->getParam('start_time');
            $paramObj->end_time1       =         $this->getParam('end_time');
            $paramObj->start_time =  strtotime($paramObj->start_time1);
            $paramObj->end_time =  strtotime($paramObj->end_time1);
            $data = ShopService::instance()->SelectInvoice($paramObj);
           return $this->view('shop.shop_user_invoice')->with(['data'=>$data,'start_time'=>$paramObj->start_time1,'end_time'=>$paramObj->end_time1,'title'=>$title]);
        }else{
            $data = ShopService::instance()->SelectInvoice($paramObj);
            return $this->view('shop.shop_user_invoice')->with(['data'=>$data,'title'=>$title]);
        }

    }
    /**
     *
     * 发票查询
     * 09。13
     *
     */
    public function SelectInvoiceAjax(){
        $paramObj                   =          new stdClass();
        $paramObj->user_id       =         session_get(UserEnum::USER_INFO_USER_ID);
        $paramObj->start_time1      =          $this->getParam('start_time');
        $paramObj->end_time1       =         $this->getParam('end_time');
        $paramObj->start_time =  strtotime($paramObj->start_time1);
        $paramObj->end_time =  strtotime($paramObj->end_time1);
        $paramObj->title      =          $this->getParam('title');
        $paramObj->status      =          $this->getParam('status');
        $data = ShopService::instance()->SelectInvoice($paramObj);
        return $data;


    }

    /**
     * @return mixed
     * 消息中心
     */
    public function ShopUserNews(){
        $paramObj                   =          new stdClass();
        $paramObj->type       =         $this->getParam('type');

        $data = ShopService::instance()->MessageList();
        ShopService::instance()->LookMessage();
        return $this->view('shop.shop_user_news')->with(['message'=>$data,'type'=>$paramObj->type]);
    }


}